package com.jianan.mis.util.ui.calendar;

import java.text.DateFormat;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Text;

public class SWTCalendarWrapper {

	public static void openCalendar(final MouseEvent e, final Text text,
			final DateFormat dateFormat) {
		if (e.button == 1) {
			final SWTCalendarDialog cal = new SWTCalendarDialog(e.display);
			cal.addDateChangedListener(new SWTCalendarListener() {
				public void dateChanged(SWTCalendarEvent calendarEvent) {
					text.setText(dateFormat.format(calendarEvent.getCalendar()
							.getTime()));
				}
			});
			cal.open();
		} else {
			text.setText("");
		}
	}
}
